import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import org.apache.commons.lang3.StringUtils;

import com.aliyun.odps.udf.UDF;

public class RemoveSameAndOrder extends UDF {

	public String evaluate(String str) {
		if (StringUtils.isNotBlank(str)) {
			// 将字符串切割
			String[] split = str.split(",");
			List<Integer> list = new ArrayList<Integer>();
			// 遍历转成int类型添加到集合
			for (String s : split) {
				list.add(Integer.parseInt(s));
			}
			// 排序
			Collections.sort(list);
			// 拼接成字符串返回
			StringBuffer sb = new StringBuffer();
			for (int i : list) {
				sb = sb.append(i).append(",");
			}
			if (sb.length() != 0) {
				String cpsId = sb.substring(0, sb.lastIndexOf(","));
				System.out.println(cpsId);
				return cpsId;
			}
		}

		return null;
	}
}
